//
//  QBDropDownMenuCollectionViewCell.swift
//  QBDropDownMenuDemo
//
//  Created by 乐启榜 on 16/7/28.
//  Copyright © 2016年 乐启榜. All rights reserved.
//

import UIKit

class QBDropDownMenuCollectionViewCell: UICollectionViewCell {
    
    var containtString: String = "" {
        didSet{
            self.label.text = containtString
        }
    }
    private lazy var label: UILabel = {
        let label: UILabel = UILabel()
        label.layer.cornerRadius = dropDownMenuCollectionViewUIValue().CELL_LABEL_CORNERRADIUS
        label.clipsToBounds = true
        label.adjustsFontSizeToFitWidth = true
        label.textAlignment = .Center
        label.font = UIFont.systemFontOfSize(dropDownMenuCollectionViewUIValue().CELL_LABEL_FONT)
        return label
    }()
    override init(frame: CGRect) {
        super.init(frame: frame)
        viewConfig()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func viewConfig() {
        weak var weakSelf = self
        self.addSubview(self.label)
        self.label.snp_makeConstraints { (make) in
            make.edges.equalTo(weakSelf!)
        }
    }
    override var selected: Bool{
        didSet{
            self.label.backgroundColor = selected ? kDropdownMenuSelectedCellColor() : UIColor.clearColor()
            self.label.textColor = selected ? UIColor.whiteColor() : kDropdownMenuUnselectedCellTextColor()
        }
    }
}
